package com.woniuxy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.aspect.LogRecord;
import com.woniuxy.dao.CarYearlyInspectionMapper;
import com.woniuxy.dto.CarYearlyInspectionDto;
import com.woniuxy.entity.CarYearlyInspection;
import com.woniuxy.service.CarYearlyInspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class CarYearlyInspectionServiceImpl implements CarYearlyInspectionService {
    @Autowired
    private CarYearlyInspectionMapper carYearlyInspectionMapper;
    /**
     * 条件查询分页查询所有
     *
     * @param condition
     * @param pageNum
     * @param pageSize
     */
    @Override
    public PageInfo<CarYearlyInspectionDto> findByPage(Map<String, Object> condition, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<CarYearlyInspectionDto> list = carYearlyInspectionMapper.findAll(condition);
        return new PageInfo<>(list);
    }

    /**
     * 添加
     *
     * @param carYearlyInspection
     */
    @LogRecord
    @Override
    public int save(CarYearlyInspection carYearlyInspection) {
        return carYearlyInspectionMapper.save(carYearlyInspection);
    }

    /**
     * 修改
     *
     * @param carYearlyInspection
     */
    @LogRecord
    @Override
    public int updateById(CarYearlyInspection carYearlyInspection) {
        return carYearlyInspectionMapper.updateById(carYearlyInspection);
    }

    /**
     * 删除
     *
     * @param id
     */
    @LogRecord
    @Override
    public int deleteById(Integer id) {
        return carYearlyInspectionMapper.deleteById(id);
    }

    /**
     * 批量删除
     *
     * @param ids
     */
    @Override
    public int deleteBatch(String[] ids) {
        return carYearlyInspectionMapper.deleteBatch(ids);
    }

    /**
     * 批量添加数据
     *
     */
    @Override
    public int insertBatch(List<CarYearlyInspectionDto> carYearlyInspectionList) {
        return carYearlyInspectionMapper.insertBatch(carYearlyInspectionList);
    }

    /**
     * 导出所有数据Excel
     */
    @Override
    public List<CarYearlyInspectionDto> findAll() {
        return carYearlyInspectionMapper.findAll(null);
    }
}
